/*
 * TimedTrack.java
 */
package behavior_analysis_model;

import behavior_analysis_control.DateUtils;

/**
 * TimedTrack is an object that contains GPS coordinates and
 * Date/Time info, with two Date/Times: Start and end time.
 * 
 * @author Sean Brown
 * @version 11/10/2012
 */
public class TimedTrack extends Track {
	
	/**
	 * The ending date/time.
	 */
	private long my_end_time;
	
	/**
	 * Constructor builds a new Track and assigns value to end time.
	 * 
	 * @param the_latitude Latitude
	 * @param the_longitude Longitude
	 * @param the_start_time Start time (long value - from origin value in 1979).
	 * @param the_end_time End time (long value - from origin value in 1979).
	 */
	public TimedTrack(final double the_latitude, final double the_longitude,
			final long the_start_time, final long the_end_time) {
		super(the_latitude, the_longitude, the_start_time);
		my_end_time = the_end_time;
	}
	
	/**
	 * Getter for the amount of time between start time and end time.
	 * 
	 * @return Total amount of time for this Timed Track.
	 */
	public long getTotalTime() {
		return  my_end_time - this.getDateTime();
	}
	
	/**
	 * Returns a string representation of this object.
	 * 
	 * @return String representation of this object.
	 */
	public String toString() {
		final StringBuilder sb = new StringBuilder();
		sb.append(this.latLongToString());
		sb.append(", Start: ");
		sb.append(DateUtils.dateTimeFormatted(getDateTime()));
		sb.append(", End: ");
		sb.append(DateUtils.dateTimeFormatted(my_end_time));
		sb.append(", Total Time: ");
		sb.append(getTotalTime() / (Analyzer.MIL_TO_SEC * Analyzer.SEC_TO_MIN));
		sb.append(" minutes.");
		return sb.toString();
	}
}
